<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="icon" href="https://static.nowcoder.com/images/logo_87_87.png"/>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
          crossorigin="anonymous">
    <link rel="stylesheet" th:href="@{/css/global.css}"/>
    <title>我的文件</title>
</head>
<body>
<div class="nk-container">
    <!-- 头部 -->
    <header class="bg-dark sticky-top" th:replace="index::header">
    </header>

    <!-- 内容 -->
    <div class="main">
        <div class="container">
            <button class="float-right btn btn-sm btn-info" data-toggle="modal" data-target="#publishModal">上传文件
            </button>
            <h6><b class="square"></b> 我的文件(<i th:text="${fileInfo.size()}"></i>)</h6>

            <!--弹出框 -->
            <div class="modal fade" id="publishModal" tabindex="-1" role="dialog" aria-labelledby="publishModalLabel"
                 aria-hidden="true">
                <div class="modal-dialog modal-lg" role="document">
                    <div class="modal-content" style="border-radius: 10px">
                        <div class="modal-header">
                            <h5 class="modal-title" style="font-weight: lighter" id="publishModalLabel">文件上传</h5>
                            <button type="button" class="close btn" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <div class="modal-body align-self-center" style="font-weight: lighter">
                            <form id="fileForm" enctype="multipart/form-data">
                                <div class="form-group">
                                    <label for="file-name" class="col-form-label">文件名(选填)：</label>
                                    <input type="text" name="fileName" style="font-weight: lighter" id="file-name">
                                </div>
                                <div class="form-group">
                                    <label for="file" class="col-form-label">文件：</label>
                                    <input type="file" onchange="fileChange()" style="font-weight: lighter"  name="file" id="file"><br>
                                    <span id="hint" style="font-size: 12px;color: red"></span>
                                </div>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" style="font-weight: lighter" class="btn btn-secondary"
                                    data-dismiss="modal">取消
                            </button>
                            <button type="button" style="font-weight: lighter" class="btn btn-primary" id="publishBtn">
                                上传
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <!--提示框-->
            <div class="modal fade" id="hintModal" tabindex="-1" role="dialog" aria-labelledby="hintModalLabel"
                 aria-hidden="true">
                <div class="modal-dialog modal-lg" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" style="font-weight: lighter" id="hintModalLabel">提示</h5>
                        </div>
                        <div class="modal-body align-self-center" style="font-weight: lighter" id="hintBody">
                        </div>
                    </div>
                </div>
            </div>

            <div th:if="${fileInfo.size()==0}" style="padding-top: 50px;padding-bottom: 50px;text-align: center">
                <span class="text-muted font-size-14" style="font-weight: lighter">空空如也~</span><br/>
                <img th:src="@{/img/nothing.png}" >
            </div>

            <!-- 文件列表 -->
            <div style="padding: 10px 25px">
                <ul class="list-unstyled" th:if="${fileInfo.size()>0}">
                    <li class="media pb-3 pt-3 mb-3 border-bottom" th:each="map:${fileInfo}">
                        <div class="media-body">
                            <div class="float-right text-muted">大小：<b th:text="${map.size}"></b></div>
                            <a class="mt-0 mb-3" style="color: #0b68b3;text-decoration: underline" th:href="@{|/file/download/${map.filename}|}" th:text="${map.filename}"></a>
                            <div class="text-muted font-size-12" style="padding-top: 5px">
                                <button type="button" th:onclick="deleteFile([[${map.filename}]]);" class="btn btn-sm btn-danger float-right">删除</button>
                                <div class="mr-3" style="padding-top: 5px">
                                    下载次数：<b th:text="${map.downloadCount}"></b><br>
                                    上传于 <b th:text="${#dates.format(map.createTime,'yyyy-MM-dd HH:mm:ss')}">2019-04-15 15:32:18</b>
                                </div>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </div>

    <!-- 尾部 -->
    <footer class="bg-dark" th:replace="index::footer">
    </footer>
</div>

<script src="https://code.jquery.com/jquery-3.3.1.min.js" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
        crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" crossorigin="anonymous"></script>
<script th:src="@{/js/global.js}"></script>
<script th:src="@{/js/myfile.js}"></script>
</body>
</html>
